<template>
	<view class="page">
		
		<!-- 消息弹窗 -->
		<quick-message ref="message"></quick-message>
		
		<view class="user-block">
			<view class="userinfo">
				<image :src="saolei.headPic" mode="" class="head_img"></image>
				<view class="nickName-count">
					<text class="nickName" v-if="isLogin">{{saolei.nickName}}</text>
					<text class="count" v-if="isLogin">
						积分:<text style="color: #ff0000;margin: 0 8rpx;">{{saolei.count}}</text>分
					</text>
					<text class="count" v-if="isLogin">
						状态:<text style="color: #ff0000;margin: 0 8rpx;" :style="{'color': saolei.status == '在线' ? '#0eff02' : '#b5b5b5' }" >{{saolei.status}}</text>
						<!-- <text class="iconfont iconzhongxinjiazai" style="margin-left: 30rpx;"></text> -->
						<!-- 状态:<text style="color: #ff0000;margin: 0 8rpx;" :style="{'color': $store.state.userStatus == '在线' ? '#0eff02' : '#b5b5b5' }" >{{$store.state.userStatus}}  </text> -->
					</text>
					<text class="nickName" v-else @click="toLogin" style="color: #007AFF;">点击登录</text>
				</view>
			</view>
			<view class="logout" v-if="isLogin">
				<!-- <text v-if="saolei.id == 1398132309700255746">退出登录</text> -->
				<text style="color: #ffaaff;" @click="toUpdate" v-if="saolei.openId == '6E8569364755ABAF09F753D817DA37AF' || saolei.openId == '2BE350D6AC8B65EECB0A06C12E06C7DD' ">发布新版</text>
				<text @click="qqLoginOut()" >退出登录</text>
			</view>
		</view>
		
		<!-- 排行榜 -->
		<view class="rank-list-block">
			
			<swiper 
			@change="swiperChange"
			:indicator-dots="true" 
			:style="{'height': screenHeight-180+'px'}">
			
			<!-- 积分排行榜Top10 -->
			<swiper-item item-id="zuiqiang">
				<view class="swiper-item">
					<view class="rank-list-title">
						<text>积分榜</text>
						<view class="">
							<text>积分</text>
							<text style="margin-left: 80rpx;">点赞</text>
						</view>
					</view>
					
					<scroll-view scroll-y="true" 
					refresher-enabled="true"
					:refresher-triggered="triggered"
					:refresher-threshold="50" 
					refresher-background="#ffffff" 
					@refresherpulling="onPulling"
					@refresherrefresh="onRefresh" 
					@refresherrestore="onRestore" 
					:style="{'height': screenHeight-220+'px'}">
						<view class="empty-text" v-if="zuiqiangList.length == 0 && errorText == ''">
							<text >冠军宝座给大侠保留着哦~</text>
						</view>
						
						<view class="empty-text" v-else-if="zuiqiangList.length == 0 && errorText != ''">
							<text>{{errorText}}</text>
						</view>
						<!-- :status="" -->
						<uni-list v-else>
						    <uni-list-item 
							v-for="(item,index) in zuiqiangList"
							:key=index
							@showInfo="showInfo(item)"
							:title="item.nickName" 
							:rank= index+1
							:rankColor = "index < 3 ? nameLabel[index].color : nameLabel[3].color"
							:color="item.status == '离线' ? '#5b5b5b' : '#00ff00'"
							:note= "item.pkStatus == 'true'&&item.status=='在线' ? 'pk中' : '手机'+item.status"
							:thumb="item.headPic"
						     thumb-size="lg" >
							 <template slot="footer">
								 <text>{{item.count}}分</text>
								 <label 
								 @click="dianzan(item.id,item.zan)"
								 :style="{'color': item.zan ? '#ffda08' : ''}"
								 class="iconfont icondianzan"
								 style="margin-left: 90rpx;"
								 ></label>
							 </template>
							 </uni-list-item>
						</uni-list>
					</scroll-view>
				</view>
			</swiper-item>
			
				
				<!-- 模式最快排行榜Top10 -->
				<swiper-item item-id="zuikuai">
					<view class="swiper-item">
						
						<view class="rank-list-title">
							<text>速度榜</text>
							<view class="picker-block">
								<text>当前模式:</text>
								<picker @change="bindPickerChange" :value="pickerIndex" 
								:range="types">
									<view class="len-picker">
										<view class="uni-input">{{types[pickerIndex]}}</view>
										<text class="iconfont iconsanjiaoxing1"></text>
									</view>
								</picker>
							</view>
							<text>成绩</text>
							<text>点赞</text>
						</view>
						
						<scroll-view scroll-y="true" 
						refresher-enabled="true" 
						:refresher-triggered="triggered"
						:refresher-threshold="50" 
						refresher-background="#ffffff" 
						@refresherpulling="onPulling"
						@refresherrefresh="onRefresh" 
						@refresherrestore="onRestore" 
						:style="{'height': screenHeight-220+'px'}">
							<view class="empty-text" v-if="zuikuaiList.length == 0 && errorText == ''">
								<text >冠军宝座给大侠保留着哦~</text>
							</view>
							
							<view class="empty-text" v-else-if="zuikuaiList.length == 0 && errorText != ''">
								<text>{{errorText}}</text>
							</view>
							
							<uni-list v-else>
							    <uni-list-item 
								v-for="(item,index) in zuikuaiList"
								:key=index
								@showInfo="showInfo(item)"
								:title="item.nickName" 
								:rank= index+1
								:rankColor = "index < 3 ? nameLabel[index].color : nameLabel[3].color"
								:color="item.status == '离线' ? '#5b5b5b' : '#00ff00'"
								:note= "item.pkStatus == 'true'&&item.status=='在线'  ? 'pk中' : '手机'+item.status"
								:thumb="item.headPic"
							     thumb-size="lg" 
								 >
								 <template slot="footer">
									 <text>{{item.requeryGrade}}''</text>
									 <label 
									 @click="dianzan(item.id,item.zan)"
									 :style="{'color': item.zan ? '#ffda08' : ''}"
									 class="iconfont icondianzan"
									 ></label>
								 </template>
								 </uni-list-item>
							</uni-list>
						</scroll-view>
						
					</view>
				</swiper-item>
				
				
				<!-- pk排行榜Top10 -->
				<swiper-item item-id="pktop">
					<view class="swiper-item">
						<view class="rank-list-title">
							<text>PK榜</text>
							<view class="">
								<text>胜场</text>
								<text style="margin-left: 80rpx;">点赞</text>
							</view>
						</view>
						
						<scroll-view scroll-y="true" 
						refresher-enabled="true"
						:refresher-triggered="triggered"
						:refresher-threshold="50" 
						refresher-background="#ffffff" 
						@refresherpulling="onPulling"
						@refresherrefresh="onRefresh" 
						@refresherrestore="onRestore" 
						:style="{'height': screenHeight-220+'px'}">
							<view class="empty-text" v-if="zuiqiangList.length == 0 && errorText == ''">
								<text >冠军宝座给大侠保留着哦~</text>
							</view>
							
							<view class="empty-text" v-else-if="zuiqiangList.length == 0 && errorText != ''">
								<text>{{errorText}}</text>
							</view>
							
							<uni-list v-else>
							    <uni-list-item 
								v-for="(item,index) in pktopList"
								:key=index
								@showInfo="showInfo(item)"
								:title="item.nickName" 
								:rank= index+1
								:rankColor = "index < 3 ? nameLabel[index].color : nameLabel[3].color"
								:status="item.pkStatus ? 'pk中' : item.status "
								:color="item.status == '离线' ? '#5b5b5b' : '#00ff00'"
								:note= "item.pkStatus == 'true'&&item.status=='在线' ? 'pk中' : '手机'+item.status"
								:thumb="item.headPic"
							     thumb-size="lg" >
								 <template slot="footer">
									 <text>{{item.pkTotal}}场</text>
									 <label 
									 @click="dianzan(item.id,item.zan)"
									 :style="{'color': item.zan ? '#ffda08' : ''}"
									 class="iconfont icondianzan"
									 style="margin-left: 90rpx;"
									 ></label>
								 </template>
								 </uni-list-item>
							</uni-list>
						</scroll-view>
					</view>
				</swiper-item>
				
				<!-- 总场次榜 -->
				<swiper-item item-id="zuiduo">
					<view class="swiper-item">
						<view class="rank-list-title">
							<text>毅力榜</text>
							<view class="">
								<text>总场次</text>
								<text style="margin-left: 80rpx;">点赞</text>
							</view>
							
						</view>
						
						<scroll-view scroll-y="true" 
						refresher-enabled="true"
						:refresher-triggered="triggered"
						:refresher-threshold="50" 
						refresher-background="#ffffff" 
						@refresherpulling="onPulling"
						@refresherrefresh="onRefresh" 
						@refresherrestore="onRestore" 
						:style="{'height': screenHeight-220+'px'}">
							<view class="empty-text" v-if="zuiduoList.length == 0 && errorText == ''">
								<text >冠军宝座给大侠保留着哦~</text>
							</view>
							
							<view class="empty-text" v-else-if="zuiduoList.length == 0 && errorText != ''">
								<text>{{errorText}}</text>
							</view>
							
							<uni-list v-else>
							    <uni-list-item 
								v-for="(item,index) in zuiduoList"
								:key=index
								@showInfo="showInfo(item)"
								:title="item.nickName" 
								:status="item.pkStatus ? 'pk中' : item.status "
								:rank= index+1
								:rankColor = "index < 3 ? nameLabel[index].color : nameLabel[3].color"
								:color="item.status == '离线' ? '#5b5b5b' : '#00ff00'"
								:note= "item.pkStatus == 'true'&&item.status=='在线' ? 'pk中' : '手机'+item.status"
								:thumb="item.headPic"
							     thumb-size="lg">
								 <template slot="footer">
									 <text>{{item.gameTotal}}场</text>
									 <label 
									 @click="dianzan(item.id,item.zan)"
									 :style="{'color': item.zan ? '#ffda08' : ''}"
									 class="iconfont icondianzan"
									 style="margin-left: 100rpx;"
									 ></label>
								 </template>
								 </uni-list-item>
							</uni-list>
						</scroll-view>
					</view>
				</swiper-item>
				<!-- 最赞榜 -->
				<swiper-item item-id="zuizan">
					<view class="swiper-item">
						<view class="rank-list-title">
							<text>人气榜</text>
							<text>被赞次数</text>
						</view>
						
						<scroll-view scroll-y="true" 
						refresher-enabled="true"
						:refresher-triggered="triggered"
						:refresher-threshold="50" 
						refresher-background="#ffffff" 
						@refresherpulling="onPulling"
						@refresherrefresh="onRefresh" 
						@refresherrestore="onRestore" 
						:style="{'height': screenHeight-220+'px'}">
							<view class="empty-text" v-if="zuizanList.length == 0 && errorText == ''">
								<text >冠军宝座给大侠保留着哦~</text>
							</view>
							
							<view class="empty-text" v-else-if="zuizanList.length == 0 && errorText != ''">
								<text>{{errorText}}</text>
							</view>
							
							<uni-list v-else>
							    <uni-list-item 
								v-for="(item,index) in zuizanList"
								:key=index
								@showInfo="showInfo(item)"
								:title="item.nickName" 
								:status="item.pkStatus ? 'pk中' : item.status "
								:rank= index+1
								:rankColor = "index < 3 ? nameLabel[index].color : nameLabel[3].color"
								:color="item.status == '离线' ? '#5b5b5b' : '#00ff00'"
								:note= "item.pkStatus == 'true'&&item.status=='在线' ? 'pk中' : '手机'+item.status"
								:thumb="item.headPic"
							     thumb-size="lg" 
								 :rightText="item.dianzanTotal+'次'">
								 </uni-list-item>
							</uni-list>
						</scroll-view>
					</view>
				</swiper-item>
			</swiper>	
			
		</view>
		
		
		<!-- 用户资料弹窗 -->
		<view class="pop-userInfo" v-if="popShow" @click="popShow = false">
			<view class="userInfo-block" @click="popShow = false">
				<view class="head-name-sex">
					<view class="userHeadPic-block">
						<image :src="userInfo.headPic" class="userHeadPic" mode=""></image>
					</view>
					<view class="name-sex">
						<text class="omit">昵称：{{userInfo.nickName}}</text>
						<text>状态：{{userInfo.status}}</text>
						<text>性别：{{userInfo.gender}}</text>
						<text>积分：{{userInfo.count}}</text>
						<text>来自：{{userInfo.type}}</text>
					</view>
				</view>
				
				<view class="grade-list">
					<view class="grade-list-itme">
						<text>模式</text>
						<text>时间</text>
						<text>最佳成绩</text>
					</view>
					<view class="" v-if="userInfo.bestGrade != ''">
						<view class="grade-list-itme" 
						v-for="item in JSON.parse(userInfo.bestGrade)"
						:key=item.id>
						<!-- <view class="grade-list-itme" v-for="i in 8"> -->
							<text>{{item.model}}</text>
							<!-- <text>{{fTime(new Date(item.createTime))}}</text> -->
							<text>{{dayjs(item.createTime).format('YYYY-MM-DD')}}</text>
							<text>{{item.grade}}''</text>
							<!-- <text>25x25</text>
							<text>2020-12-21</text>
							<text>1213''</text> -->
						</view>
					</view>
				</view>
				<button v-if="userInfo.id != saolei.id" type="default" class="pop-btn" @click="toPkSetting(userInfo)">发起挑战</button>
			</view>
			
		</view>
	</view>
</template>

<script>
	
	import utils from "../../common/util.js"
	import uniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
	var _self
	var lastPopTime
	var lastCancelTime
	
	export default {
		data() {
			return {
				// qq授权登录对象
				aqq: null,
				awx: null,
				// 当前环境支持的所有授权登录对象
				auths: [],
				screenHeight: uni.getSystemInfoSync().screenHeight,
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				types:["8x8","10x10","12x12","15x15","18x18","20x20","25x25"],
				pickerIndex: 0,
				faceImage: '',
				nickName: '',
				isLogin: false,
				triggered: false, // 是否下拉标注
				_freshing: false,
				popShow: false, // 弹窗标志
				userInfo:{},
				saolei: {
					id: 0
				},
				nameLabel:[
					{
						name:"最强王者",
						color:"#ff0000"
					},
					{
						name:"永恒钻石",
						color:"#00aa00"
					},
					{
						name:"荣耀黄金",
						color:"#00aaff"
					},
					{
						name:"嘴强王者",
						color:"grey"
					}
				],
				zuikuaiList:[],
				zuiqiangList:[],
				zuizanList:[],
				zuiduoList:[],
				pktopList:[],
				currentItemId: "zuiqiang",
				type: "",
				errorText:"",
				dayjs: require('dayjs')
			}
		},
		onLoad(data) {
			_self = this
			this._freshing = false;
			
			// 判断是否登录
			var userInfo =  uni.getStorageSync("saolei_userInfo")
			if(userInfo){
				_self.saolei = userInfo
				_self.isLogin = true
			}else {
				_self.isLogin = false
			}
			
			_self.type = this.$store.state.new_model
			_self.pickerIndex = _self.types.indexOf(this.$store.state.new_model)
			uni.showLoading({
				mask:false,
				title:"数据加载中....."
			})
			_self.choiseTop()
			// 定时获取排名消息
			setInterval(function(){
				//打开webSocket
				if(_self.saolei.status == "离线"){
					utils.connectSocketInit()
				}
				_self.choiseTop()
			},2000)
			this.Init()
		},
		onPullDownRefresh() {
			// uni.redirectTo({
			// 	url:"../white/white?returnUrl=../me/me"
			// })
			//打开webSocket
			if(!this.$store.state.start_timeId){
				utils.connectSocketInit()
			}
			this.saolei = uni.getStorageSync("saolei_userInfo")
			this._freshing = true
			uni.showLoading({
				mask:false,
				title:"数据加载中....."
			})
			uni.stopPullDownRefresh()
			_self.choiseTop()
		},
		onShow(){
			utils.setUserPkStatus("false")
			//打开webSocket
			// if(!_self.$store.state.start_timeId){
			// 	utils.connectSocketInit()
			// }
			_self.choiseTop()
			_self.Init()
		},
		onNavigationBarButtonTap(e) {
			if(e.type == "share"){
				_self.uniShare()
			}
		},
		beforeDestroy() {
			// utils.closeSocket()
		},
		computed:{
			userStatus(userInfo){
				if(userInfo.pkStatus){
					return "pk中"
				}else{
					return userInfo.pkStatus
				}
			}
		},
		methods: {
			fTime(time){
				console.log(time);
				return utils.dateFormat(time,'Y-m-d')
			},
			Init() {
				
				plus.oauth.getServices(function(services){
					// console.log(services)
					_self.auths=services;
					services.forEach(service =>{
						if(service.id == "qq"){
							// console.log(service)
							_self.aqq = service;
						}
						
						if(service.id == "weixin"){
							// console.log(service)
							_self.awx = service;
						}
					})
				}, function(e){
					plus.nativeUI.alert("获取登录授权服务列表失败："+JSON.stringify(e));
				} );
				
				var userInfo =  uni.getStorageSync("saolei_userInfo")
				if(userInfo){
					_self.saolei = userInfo
					_self.isLogin = true
				}else {
					_self.saolei ={}
					_self.saolei.headPic = "../../static/qq.jpeg"
					_self.isLogin = false
					_self.saolei.id = 0
				}
			},
			onPulling(e) {
				// console.log("onpulling", e);
			},
			onRefresh() {
				// uni.redirectTo({
				// 	url:"../white/white?returnUrl=../me/me"
				// })
				if (this._freshing) return;
				this._freshing = true;
				this.triggered = true
				this.$nextTick(function(){
					_self.choiseTop()
				})
				//打开webSocket
				if(!_self.$store.state.start_timeId){
					utils.connectSocketInit()
				}
			},
			onRestore() {
				this.triggered = 'restore'; // 需要重置
				// console.log("onRestore");
			},
			choiseTop(){
				_self.errorText = ""
				if(_self.currentItemId == "zuikuai"){
					_self.zuikuaiTop()
				}else if(_self.currentItemId == "zuiqiang"){
					_self.zuiqiangTop()
				}else if(_self.currentItemId == "zuizan"){
					_self.zuizanTop()
				}else if(_self.currentItemId == "pktop"){
					_self.pkTop()
				}else{
					_self.zuiduo()
				}
			},
			// 滑块滑动触发
			swiperChange(event){
				_self.currentItemId = event.detail.currentItemId
				// console.log(event.detail)
				this.$nextTick(function(){
					_self.choiseTop()
				})
			},
			bindPickerChange: function(e) {
				// console.log('picker发送选择改变，携带值为', e.target.value,this.array[e.target.value] )
				_self.pickerIndex = e.target.value
				_self.type = this.types[e.target.value] 
				// this.length = this.types[e.target.value] 
				uni.showLoading({
					mask:false,
					title:"数据加载中....."
				})
				_self.choiseTop()
			},
			showInfo(user){
				// console.log(user)
				this.popShow = true
				this.userInfo = user
			},
			dianzan(receiver,flag){
				if(_self.isLogin){
					if(receiver == _self.saolei.id){
						uni.showToast({
							icon:"none",
							title: '不能给自己点赞哦 (･ิω･ิლ)',
							position:"center",
						})
						return
					}
					if(flag){
						uni.showToast({
							icon:"none",
							title: '没想到吧，点赞无法取消<(￣︶￣)> ',
							position:"center"
						})
						return
					}
					
					// 遍历点赞
					_self.zuikuaiList.forEach(zuikuai =>{
						if(zuikuai.id  == receiver){
							zuikuai.zan = true
						}
					})
					_self.zuiqiangList.forEach(zuiqiang =>{
						if(zuiqiang.id  == receiver){
							zuiqiang.zan = true
						}
					})
					_self.zuiduoList.forEach(zuiduo =>{
						if(zuiduo.id  == receiver){
							zuiduo.zan = true
						}
					})
					
					
					
					uni.request({
						url: utils.basicUrl+"/saoleiDianzhan",
						method: "POST",
						data: {
							"provider": _self.saolei.id,
							"receiver": receiver
						},
						success: function(res) {
							if(res.data.code === 20000){
								//更新数据
								_self.choiseTop()
							}else if(res.data.code == 20001 && res.data.message == "已点赞"){
								uni.showToast({
									icon:"none",
									title: '没想到吧，点赞无法取消<(￣︶￣)> ',
									position:"center"
								})
							}else{
								_self.utils.requestFail(res)
								// uni.showToast({
								// 	icon:"none",
								// 	title: res.data,
								// 	position:"center"
								// })
							}
						},
						fail: () => {
							uni.showToast({
								icon:"none",
								title: '网络错误(⊙ˍ⊙)',
								position:"center"
							})
						},
						complete() {
							uni.hideLoading()
						}
					})
				}else{
					uni.showModal({
					    title: '未登录',
					    content: '登录后才能点赞哦╮(╯▽╰)╭',
						cancelText:"再看看",
					    success: function (res) {
					        if (res.confirm) {
								_self.toLogin()
					        }else{
								return
							}
					    }
					});
				}
			},
			zuikuaiTop(){
				uni.request({
					url: utils.basicUrl+"/saoleiUser/top10/"+_self.type+"/"+_self.saolei.id,
					method: "GET",
					data: {},
					success: function(res) {
						if(res.data.code === 20000){
							res.data.data.forEach(dt => {
								if(dt.id == _self.saolei.id){
									_self.saolei = dt
									uni.setStorageSync("saolei_userInfo",dt)
								}
							})
							_self.zuikuaiList = res.data.data
						}else{
							// _self.utils.requestFail(res)
							_self.zuikuaiList = []
							_self.errorText = "获取数据失败！请联系管理员╮(╯▽╰)╭"
							
						}
					},
					fail: () => {
						_self.zuikuaiList = []
						_self.errorText = "网络错误╮(╯▽╰)╭"
					},
					complete() {
						uni.hideLoading()
						_self.triggered = false;
						_self._freshing = false;
					}
				})
			},
			zuiqiangTop(){
				uni.request({
					url: utils.basicUrl+"/saoleiUser/count/"+_self.saolei.id,
					method: "GET",
					data: {},
					success: function(res) {
						if(res.data.code === 20000){
							res.data.data.forEach(dt => {
								if(dt.id == _self.saolei.id){
									_self.saolei = dt
									uni.setStorageSync("saolei_userInfo",dt)
								}
							})
							_self.zuiqiangList = res.data.data
						}else{
							// _self.utils.requestFail(res)
							_self.zuiqiangList = []
							_self.errorText = "获取数据失败！请联系管理员₍ ᐢ. ̫ .ᐢ ₎ ​​​"
						}
					},
					fail: () => {
						_self.zuiqiangList = []
						_self.errorText = "网络错误ʕ•ﻌ•ʔ ​​​"
					},
					complete() {
						uni.hideLoading()
						_self.triggered = false;
						_self._freshing = false;
						
					}
				})
			},
			zuizanTop(){
				uni.request({
					url: utils.basicUrl+"/saoleiUser/dianZan",
					method: "GET",
					data: {},
					success: function(res) {
						if(res.data.code === 20000){
							res.data.data.forEach(dt => {
								if(dt.id == _self.saolei.id){
									_self.saolei = dt
									uni.setStorageSync("saolei_userInfo",dt)
								}
							})
							_self.zuizanList = res.data.data
						}else{
							// _self.utils.requestFail(res)
							_self.zuizanList = []
							_self.errorText = "获取数据失败！请联系管理员( ๑ˊ•̥▵•)੭₎₎"
						}
					},
					fail: () => {
						_self.zuizanList = []
						_self.errorText = "网络错误( ๑ˊ•̥▵•)੭₎₎"
					},
					complete() {
						uni.hideLoading()
						_self.triggered = false;
						_self._freshing = false;
					}
				})
			},
			zuiduo(){
				uni.request({
					url: utils.basicUrl+"/saoleiUser/gameTotal/"+_self.saolei.id,
					method: "GET",
					data: {},
					success: function(res) {
						if(res.data.code === 20000){
							res.data.data.forEach(dt => {
								if(dt.id == _self.saolei.id){
									_self.saolei = dt
									uni.setStorageSync("saolei_userInfo",dt)
								}
							})
							_self.zuiduoList = res.data.data
						}else{
							// _self.utils.requestFail(res)
							_self.zuiduoList = []
							_self.errorText = "获取数据失败！请联系管理员꒰*´◒`*꒱"
						}
					},
					fail: () => {
						_self.zuiduoList = []
						_self.errorText = "网络错误꒰*´◒`*꒱"
					},
					complete() {
						uni.hideLoading()
						_self.triggered = false;
						_self._freshing = false;
					}
				})
			},
			pkTop(){
				uni.request({
					url: utils.basicUrl+"/saoleiUser/pkTotal/"+_self.saolei.id,
					method: "GET",
					data: {},
					success: function(res) {
						if(res.data.code === 20000){
							res.data.data.forEach(dt => {
								if(dt.id == _self.saolei.id){
									_self.saolei = dt
									uni.setStorageSync("saolei_userInfo",dt)
								}
							})
							_self.pktopList = res.data.data
						}else{
							// _self.utils.requestFail(res)
							_self.pktopList = []
							_self.errorText = "获取数据失败！请联系管理员(๑•ૅૄ•๑) "
						}
					},
					fail: () => {
						_self.pktopList = []
						_self.errorText = "网络错误(๑•ૅૄ•๑)  "
					},
					complete() {
						uni.hideLoading()
						_self.triggered = false;
						_self._freshing = false;
					}
				})
			},
			toPkSetting(userInfo){
				if(!_self.isLogin){
					uni.showModal({
						title:"提示",
						content:"登录了才能发起挑战哦 ｡°(°¯᷄◠¯᷅°)°｡",
						success: function (res) {
						    if (res.confirm) {
								uni.navigateTo({
									url:"../addAndRegister/addAndRegister",
									animationDuration:400,
									animationType:"slide-in-bottom"
								})
						    }  else if (res.cancel) {
								return
							}
						}
					})
				}else if(userInfo.status == "离线"){
					uni.showToast({
						icon:"none",
						title:"对方不在线啊(σ｀・д･)σ",
						position:"center"
					})
				}else if(userInfo.pkStatus == "true"){
					uni.showToast({
						icon:"none",
						title:"对方正在PK中呢(｡≖‿≖｡) ",
						position:"center"
					})
				}else{
					uni.showModal({
					    title:"提示",
					    content:"pk成绩只计入pk成绩而不计入个人成绩哦  (=￣ω￣=)",
					    success: function (res) {
					        if (res.confirm) {
					            uni.navigateTo({
					            	url:"../pkSetting/pkSetting?opponetId="+userInfo.id,
					            	animationDuration:400,
					            	animationType:"slide-in-right"
					            })
					        }
					    }
					});
				}
				
			},
			toLogin(){
				uni.navigateTo({
					url:"../addAndRegister/addAndRegister",
					animationType:"slide-in-bottom",
					animationDuration:400
				})
			},
			toUpdate(){
				uni.navigateTo({
					url:"../update/update",
					animationType:"zoom-fade-out",
					animationDuration:300
				})
			},
			qqLoginOut(){
				this.utils.closeSocket()
				if(_self.aqq){
					_self.aqq.logout(function(e){
						uni.showToast({
							icon:"none",
							title:"已退出qq .^◡^. ",
							position:"center"
						})
					})
				}
				
				if(_self.awx){
					_self.awx.logout(function(e){
						uni.showToast({
							icon:"none",
							title:"已退出wx .^◡^. ",
							position:"center"
						})
					})
				}
				
				uni.removeStorageSync("saolei_userInfo")
				this.Init()
				this.choiseTop()
			},
			uniShare() {
				uniShare({
					content: { //公共的分享参数配置  类型（type）、链接（herf）、标题（title）、summary（描述）、imageUrl（缩略图）
						type: 0,
						href: 'https://saolei.xiaohong.work',
						title: '扫雷·联机版',
						summary: '我的排名又上升了,快来和我一起PK吧!',
						imageUrl: '/static/28x28.png'
					},
					menus: [{
							"img": "/static/app-plus/sharemenu/wechatfriend.png",
							"text": "微信好友",
							"share": { //当前项的分享参数配置。可覆盖公共的配置如下：分享到微信小程序，配置了type=5
								"provider": "weixin",
								"scene": "WXSceneSession"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/wechatmoments.png",
							"text": "微信朋友圈",
							"share": {
								"provider": "weixin",
								"scene": "WXSenceTimeline"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/qq.png",
							"text": "QQ",
							"share": {
								"provider": "qq"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/copyurl.png",
							"text": "复制",
							"share": "copyurl"
						},
						{
							"img": "/static/app-plus/sharemenu/more.png",
							"text": "更多",
							"share": "shareSystem"
						}
					],
					cancelText: "取消分享",
				}, e => { //callback
					console.log(e);
				})
			}
		}
	}
</script>

<style>
	@import url("me.css");
</style>
